package gobase

type UintFlags[T Unsigned] struct {
	value T
}

// Set the flag
func (cf *UintFlags[T]) Set(c T) {
	cf.value |= c
}

// Clear the flag
func (cf *UintFlags[T]) Clear(c T) {
	cf.value &^= c
}

// IsSet returns true if the flag is Set, false otherwise
func (cf UintFlags[T]) IsSet(c T) bool {
	return cf.value&c != 0
}

// SetIfNotSet will Set the flag `c` if that flag was not already
func (cf *UintFlags[T]) SetIfNotSet(c T) bool {
	if cf.value&c == 0 {
		cf.value |= c
		return true
	}
	return false
}
